'use strict';

var fs = require('fs');
var bodyParser = require('body-parser');
bodyParser({ keepExtensions: true, uploadDir: './' });
var formidable = require('formidable');

module.exports = function (router) {


    router.get('/', function (req, res) {
        res.render('upload');
        //        res.redirect('/');
    });


    router.post('/', function (req, res) {
        console.log(bodyParser(req));
        // var form = new formidable.IncomingForm({keepExtensions: true, uploadDir: '/home/guo/workspace/zyw' });
        // form.parse(req, function(err, fields, files) {
        //     console.log('sss');
        //     if (err) {
        //         console.log(err);
        //     } else {
        //         console.log(files);
        //     }
        // });
        res.redirect('/upload');
    });
};
